package test3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2023-11-24
 * Time: 21:23
 */
public class test {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6};
        String str = arrToString(arr);
        System.out.println(str);

    }

    public static String arrToString(int[] arr) {
        if (arr == null) {
            return "";
        }
        if (arr.length == 0) {
            return "[]";
        }

        String result = "[";
        for (int i = 0; i < arr.length; i++) {
            if(i==arr.length-1){
                result = result + arr[i];
            }else {
                result = result + arr[i]+',';
            }

        }
        result = result + "]";
        return result;
    }
}
